<?php
class image_c extends CI_Controller {
	function __construct() {
		parent::__construct ();
		$this->load->helper ( 'url' );
		// 加载验证码类
		session_start();
		$this->load->library ( 'authcode' );
	}
	function index() {
		$this->authcode->show ();
	}
	function check() {
		$vertify = $_POST[$_POST["index"]];
		if ($this->authcode->check ( strtolower ( $vertify ) )) {
			$tu ["state"] = "1";     //成功
		} else {
			$tu ["state"] = "0";
			$tu ["msg"] = "验证码错误！";
		}
		echo json_encode($tu);
	}
	function check_db() {
		if ($_POST ["index"] == "over_mail") {     //判断邮箱是否一致
			if ($_POST ["tjb_box"] == md5($_POST [$_POST ["index"]])) {
				$tu ["state"] = "1";
			} else{
				$tu ["state"] = "0";
				$tu ["usermail"] = "您输入的邮箱地址不一致";
			}
		} else {
			$map [$_POST ["index"]] = $_POST [$_POST ["index"]];
			$re = $this->m_tbk->getOne ( "user", $map );
			if ($re) {
				$tu ["state"] = "1";
				$tu ["box"] = md5($re ["usermail"]);
				$s = $re ["usermail"];
				$in = strpos ( $s, "@" );
				$len = strlen ( $s );
				$str = $s [0] . "*****" . substr ( $s, $in - 1 );
				$tu ["usermail"] = $str;
			} else {
				$tu ["state"] = "0";
				$tu ["usermail"] = "账号不存在";
			}
		}
		echo json_encode ( $tu );
	}
}